<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.css">
    <style>
        h3 {
            float: left;
        }
    </style>


    <%
        int year = Integer.parseInt(org.apache.commons.lang.time.DateFormatUtils.format(new java.util.Date(), "yyyy"));
    %>

</head>
<body>
<hr>

<input style="float: right;" type="button" class="btn btn-success btn-s-xs" onclick="chiody()" id="id1" value="打印"/> 


选择员工:<select name="pets" id="test" onchange="gradeChange()">
    <option value="">${user.NAME}</option>
    <option value="李四">李四</option>
    <option value="王五">王五</option>
    <option value="林一">林一</option>
    <option value="陈三">陈三</option>
    <option value="吕六">吕六</option>
    <option value="刘五">刘五</option>
    <option value="俞大">俞大</option>
</select>

<h1  align="center">员工月度订单汇总</h1>


<table width="100%" >

    <div >
        <tr>
            <th align="left">员工姓名:&nbsp;&nbsp;&nbsp;&nbsp;${user.NAME}</th>
            <th align="center"> 联系电话:&nbsp;&nbsp;&nbsp;&nbsp;${user.tel}</th>
            <th align="right" width="300px">
                统计年月:
            <form  action="selectsServlet"method="get">

                <select id="birthYear" name="birthYear" class="date">
                    <option value="">${year}</option>
                    <c:forEach begin="2000" end="<%=year %>" var="year">
                        <option value="${year}">${year }</option>
                    </c:forEach>
                </select>
                <select id="birthMonth" name="birthMonth" class="month">
                    <option value="">${month }</option>
                    <c:forEach begin="1" end="12" var="month">
                        <option value="${month }">${month }</option>
                    </c:forEach>
                </select>
                <button type="submit">提交</button>
            </form>
            </th>
<%--            <th > 统计月份: ${i}年${y}月</th>--%>
        </tr>
    </div>

</table>

<hr>
<form id="select" >
<table align="center"class="table table-striped" border="1" cellspacing="0" width="100%">
    <tr>
        <th>序号</th>
        <th>创建时间</th>
        <th>菜名</th>
        <th>单位</th>
        <th>分量</th>
        <th>单价</th>
        <th>总价</th>
    </tr>
    <c:forEach items="${orderList}" var="order" varStatus="status">

    <c:forEach items="${order.orderItems}" var="orderItem" >
        <tr align="center">
            <td>${status.count}</td>
            <td>${orderItem.createtime}</td>
            <td>${orderItem.goodsName}</td>
            <td>${orderItem.unit}</td>
            <td>${orderItem.count}</td>
            <td>￥${orderItem.price}</td>
            <td>￥${orderItem.subTotal}</td>
        </tr>

    </c:forEach>

    </c:forEach>




</table>
    <c:set var="sum" value="0"></c:set>
    <c:forEach items="${orderList}" var="order">

            <c:forEach items= "${order.orderItems}" var="row" varStatus="status">
                <c:set var="sum"  value="${sum+(row.subTotal)}"/>
            </c:forEach>


    </c:forEach>
    <div align="right">
        合计:<font color="red">

    ${sum}
    </font>元
    </div>
</form>
<hr>
<h3  style="width: 40%"> 操作员:${user1.NAME}</h3>  <h3  style="width: 60%" align="right"> 操作时间:${t}</h3>
<hr>
<script>
    <%--document.getElementById("add").onclick=function () {--%>
    <%--    location.href="/add-demo/addBrand.html";--%>
    <%--}--%>
    <%--function deleteServlet(id) {--%>
    <%--    if(confirm("你确定要删除吗？")){--%>
    <%--        location.href="${pageContext.request.contextPath}/deleteServlet?id="+id;--%>
    <%--    }--%>
    <%--}--%>
    function gradeChange(){
        var myselect=document.getElementById("test");
        var index=  myselect.options[myselect.selectedIndex].text;
        var value=  myselect.options[myselect.selectedIndex].value;
        if (value === "李四") {
            location.href="/login/selectUserServlet?uid=1"
        }
        if (value === "王五") {

            location.href="/login/selectUserServlet?uid=2"
        }
        if (value === "林一") {

            location.href="/login/selectUserServlet?uid=3"
        }
        if (value === "陈三") {

            location.href="/login/selectUserServlet?uid=4"
        }
        if (value === "吕六") {

            location.href="/login/selectUserServlet?uid=5"
        }
        if (value === "刘五") {

            location.href="/login/selectUserServlet?uid=6"
        }
        if (value === "俞大") {
            location.href="/login/selectUserServlet?uid=7"
        }



    }


    function chiody() {
        //来个网页提示
        if (confirm('确认打印吗？')){
            //隐藏不需要打印的内容，上面的id在这块就被用到了
            document.getElementById('id1').style.display="none";
            //执行打印方法，建议Chrome，可以预览打印内容
            window.print();
            //放开隐藏的内容
            document.getElementById('id1').style.display="inline";
        }
    }



    // var grade = objS.options[objS.selectedIndex].grade;
    // selectedIndex代表的是你所选中项的index
    //
    // myselect.options[index].text;

</script>

</body>
</html>